<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script src="vue.js"></script>
<body>
    <div id="app">
        <ul>
            <school v-for="(item,index)  in schoollist" :school-name="item" :key="index" v-on:choosename="chooseEvent"></school>  
        </ul>
        <h1 style="color:#872657">选中学校：{{this.chooseSchool}}</h1>
    </div>
    <script>
        var vm = new Vue({
            el:'#app',
            data:{
                schoollist:['安阳师范学院','安阳工学院','河南护理学院'],
                chooseSchool:'',
            },
            methods:{
                chooseEvent(name){
                    this.chooseSchool=name;
                }
            },

            components:{
                school:{
                     props:['schoolName'],
                     template:`<li>
                     <h3>学校名：{{this.schoolName}}</h3>
                     <button @click="changeEvent(schoolName)">选中学校</button>
                     </li>`,

                     methods:{
                         changeEvent(name){
                                console.log(name);
                                this.$emit('choosename',name);
                                // console.log(this);
                         }
                     }

                }
            }
        })
    </script>
</body>
</html>